package collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ArrayToListDemo {
    public static void main(String[] args) {
        String[] arr = {"one", "two", "three"};
        System.out.println(Arrays.toString(arr));

        List<String> list = Arrays.asList(arr);
        System.out.println(list);

        /*
            对该集合或数组操作,他们都可以看到改后的结果
         */
        list.set(0,"six");
        System.out.println(list);
        System.out.println(Arrays.toString(arr));
        arr[0] = "seven";
        System.out.println(list);
        System.out.println(Arrays.toString(arr));
        /*
          不支持      操作      异常
          UnsupportedOperationException
         */
        //list.remove(0);
        System.out.println(list);
        System.out.println(Arrays.toString(arr));
        //list.add("eight");


        List<String> list2 = new ArrayList<>(list);
        System.out.println("list2 = "+list2 );
        list2.add("eight");
        System.out.println("list2 = "+list2 );

    }
}
